package com.huaxin.hxcloud.find;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.Entity.FindInfo;
import com.huaxin.common.Global;
import com.huaxin.common.media.ImageGalleryActivity;
import com.huaxin.common.utils.StringUtils;
import com.huaxin.common.utils.ToastUtil;
import com.huaxin.common.view.avatarimageview.AvatarImageView;
import com.huaxin.common.view.avatarimageview.HxAvatarImageGlide;
import com.huaxin.common.view.nicegridview.NineGridLayout;
import com.huaxin.common.view.popupwindow.HxCommonPopupWindow;
import com.huaxin.hxcloud.R;
import com.huaxin.hxcloud.find.view.CollectDataEventBus;
import com.huaxin.hxcloud.find.view.FocusDataEventBus;
import com.huaxin.hxcloud.find.view.HxCommentContentEventBus;
import com.huaxin.hxcloud.find.view.LikeDataEventBus;
import com.huaxin.hxcloud.frendcircles.AnimationTools;
import com.huaxin.hxcloud.frendcircles.FrendCircleActivity;
import com.huaxindata.im.constants.ImConstants;
import com.huaxindata.im.main.contactview.friend.HxPersonalCenterActivity;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.huaxin.hxcloud.R.id.find_guanzhu_txt;


/**
 *
 */

public class FindAdapter extends BaseQuickAdapter<FindInfo.QuestionListBean, FindAdapter.FindViewHolder> {

    private Context             mContext;
    private Activity            mActivity;
    private HxCommonPopupWindow mPopupWindow;

    public FindAdapter(Context context, @Nullable List<FindInfo.QuestionListBean> data) {
        super(R.layout.item_find_text, data);
        this.mContext = context;
        this.mActivity = (Activity) context;
    }


    /**
     * 刷新收藏数据
     *
     * @param questionid
     * @param iscollect
     * @param collectNum
     */
    public void refreshCollectData(int questionid, boolean iscollect, int collectNum) {
        for (int i = 0; i < getData().size(); i++) {
            if (questionid == getData().get(i).getQuestionId()) {
                getData().get(i).setCollectionNum(collectNum);
                getData().get(i).setIsCollection(iscollect);
            }
        }
        notifyDataSetChanged();
    }

    /**
     * 添加评论数据到adapter 中
     *
     * @param commentArrBean
     * @param questionId
     * @param commentState   1  添加 0 删除
     */
    public void refreshCommentSucceedData(FindInfo.QuestionListBean.PartialTopCommentArrBean commentArrBean, int questionId, int commentState) {
        for (int i = 0; i < getData().size(); i++) {
            if (questionId == getData().get(i).getQuestionId()) {
                switch (commentState) {
                    case HxCommentContentEventBus.ADD_COMMENT:
                        if (getData().get(i).getPartialTopCommentArr().size() < 3) {
                            getData().get(i).getPartialTopCommentArr().add(commentArrBean);
                        }
                        break;
                    case HxCommentContentEventBus.DELECT_COMMENT://删除屏蔽
                       /* for (int j = 0; j < getData().size(); j++) {
                            for (int k = 0; k < getData().get(j).getPartialTopCommentArr().size(); k++) {
                                //根据评论的内容的去判断
                                if (commentArrBean.getContent().equals(getData().get(j).getPartialTopCommentArr().get(k).getContent())) {
                                    getData().get(j).getPartialTopCommentArr().remove(k);
                                }
                            }
                        }*/
                        break;
                    default:
                        break;
                }
            }
        }
        notifyDataSetChanged();
    }

    /**
     * 刷新 点赞数据
     *
     * @param questionid
     * @param islike      true 点赞成功 false 取消点赞
     * @param likeNum
     * @param likeerArray
     */
    public void refreshListData(int questionid, boolean islike, int likeNum, FindInfo.LikeerArrayBean likeerArray) {

        for (int i = 0; i < getData().size(); i++) {
            if (questionid == getData().get(i).getQuestionId()) {
                getData().get(i).setLikeerNum(likeNum);
                getData().get(i).setIsLike(islike);
                List<FindInfo.LikeerArrayBean> likeerArrayBeanList = getData().get(i).getLikeerArray();
                //当isLike
                if (islike) {
                    FindInfo.LikeerArrayBean mArrayBean = new FindInfo.LikeerArrayBean();
                    mArrayBean.setId(likeerArray.getId());
                    mArrayBean.setNickName(likeerArray.getNickName());
                    mArrayBean.setImg(likeerArray.getImg());
                    //加载集合的第一条
                    likeerArrayBeanList.add(0, likeerArray);
                } else {
                    for (int j = 0; j < likeerArrayBeanList.size(); j++) {
                        if (likeerArray.getId() == likeerArrayBeanList.get(j).getId()) {
                            likeerArrayBeanList.remove(j);
                        }
                    }
                }
            }

        }
        notifyDataSetChanged();
    }

    /**
     * 刷新关注
     *
     * @param userid
     * @param isfocus
     */
    public void refreshFocusData(int userid, boolean isfocus) {
        for (int i = 0; i < getData().size(); i++) {
            if (userid == getData().get(i).getPublisher().getId()) {
                getData().get(i).setIsFan(!isfocus);
            }
        }
        notifyDataSetChanged();
    }


    /**
     * 刷新 评论 关注 点赞
     *
     * @param questionId
     * @param isLike
     * @param likeNum
     * @param isCollect
     * @param collentNum
     * @param commentCount
     */
    public void refreshCommentData(int questionId, boolean isLike, int likeNum, boolean isCollect, int collentNum, int commentCount
            , List<FindInfo.LikeerArrayBean> likeerArray) {
        for (int i = 0; i < getData().size(); i++) {
            FindInfo.QuestionListBean listBean = getData().get(i);
            if (questionId == listBean.getQuestionId()) {

                listBean.setIsLike(isLike);
                listBean.setLikeerNum(likeNum);

                listBean.setIsCollection(isCollect);
                listBean.setCollectionNum(collentNum);

                listBean.setCommentNum(commentCount);

                listBean.getLikeerArray().clear();
                listBean.getLikeerArray().addAll(likeerArray);
                listBean.getPartialTopCommentArr();
            }
        }
        notifyDataSetChanged();

    }


    @Override
    protected void convert(FindViewHolder viewHolder, final FindInfo.QuestionListBean questionBean) {
        FindInfo.QuestionListBean.Publisher publisher = questionBean.getPublisher();
        //设置头像
        HxAvatarImageGlide instance = HxAvatarImageGlide.getInstance();
        instance.setHeadImage(mContext, publisher.getUserImg(), publisher.getNickName(), viewHolder.mFindIcon);
        //昵称
        viewHolder.mItemFindNiceName.setText(("" + publisher.getNickName()));
        String publishDate = questionBean.getPublishDate();
        final long parseLong = Long.parseLong(publishDate);
        viewHolder.mItemFindInfoTime.setText(("" + StringUtils.friendlyTime(new Date(parseLong))));
        //自已时，不显示关注
        if (Global.user.getUserId() == publisher.getId()) {
            viewHolder.mFindGuanzhuTxt.setVisibility(View.GONE);
            viewHolder.mItemFindInfoDelete.setVisibility(View.VISIBLE);
        } else {
            viewHolder.mFindGuanzhuTxt.setVisibility(View.VISIBLE);
            viewHolder.mItemFindInfoDelete.setVisibility(View.GONE);
        }
        //关注
        boolean isFan = questionBean.isIsFan();
        setChangeFcousTv(viewHolder.mFindGuanzhuTxt, isFan);
        if (!"".equals(questionBean.getContent())) {
            viewHolder.mFindContentTxt.setVisibility(View.VISIBLE);
            viewHolder.mFindContentTxt.setText(("" + questionBean.getContent()));
        } else {
            viewHolder.mFindContentTxt.setVisibility(View.GONE);
        }
        //
        if (null != questionBean.getImgUrls()) {
            viewHolder.mFindGridView.setVisibility(View.VISIBLE);
            final List<String> imgUrls = questionBean.getImgUrls();

            //缩略图
            //HxImgThumbnailUtils.getImg(imgUrls)

            viewHolder.mFindGridView.loadUriList(imgUrls);
            viewHolder.mFindGridView.setOnClickImageListener(new NineGridLayout.onClickImageListener() {
                @Override
                public void onClickNineImage(int position, View view, String url, ArrayList<String> urlList) {
                    Intent intent = new Intent(mContext, ImageGalleryActivity.class);
                    intent.putExtra("realPosition", position);
                    intent.putStringArrayListExtra("images", (ArrayList<String>) imgUrls);
                    mContext.startActivity(intent);
                }
            });
            //viewHolder.mFindGridView.setAdapter(new ImgsAdapter(imgUrls, mContext));
           /* viewHolder.mFindGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Intent intent = new Intent(mContext, ImageGalleryActivity.class);
                    intent.putExtra("realPosition", position);
                    intent.putStringArrayListExtra("images", (ArrayList<String>) imgUrls);
                    mContext.startActivity(intent);
                }
            });*/
        } else {
            viewHolder.mFindGridView.setVisibility(View.GONE);
        }
        //评论个数
        viewHolder.mFindComment.setText(("" + questionBean.getCommentNum()));


        //收藏***********//
        //收藏个数
        int collectionNum = questionBean.getCollectionNum();
        Log.d(TAG, "convert: - --->" + collectionNum);
        //是否收藏
        boolean isCollection = questionBean.isIsCollection();
        viewHolder.mFindCollect.setText((collectionNum + ""));
        setChangeCollectImg(viewHolder.mFindCollect, isCollection);
        //收藏***********//

        //点赞***********//
        boolean islike = questionBean.isIsLike();
        int likeerNum = questionBean.getLikeerNum();
        Log.d(TAG, "convert: ---->" + likeerNum);
        viewHolder.mFindZan.setText(("" + likeerNum));
        setChangeZanImg(viewHolder.mFindZan, islike);
        //点赞***********//


        viewHolder.addOnClickListener(R.id.item_find_ll_layout);

        //点赞Adapter
        viewHolder.mPraiseRecycler.setLayoutManager(new GridLayoutManager(mContext, 9));
        viewHolder.mPraiseRecycler.setHasFixedSize(true);
        List<FindInfo.LikeerArrayBean> likeerArray = questionBean.getLikeerArray();

        final HxPraiseAdapter praiseAdapter = new HxPraiseAdapter(mContext);
        praiseAdapter.setNewData(likeerArray);

        viewHolder.mPraiseRecycler.setAdapter(praiseAdapter);
        if (likeerArray.size() == 0) {
            viewHolder.mLoveFlagTv.setVisibility(View.VISIBLE);
            viewHolder.mPraiseRecycler.setVisibility(View.GONE);
        } else {
            viewHolder.mLoveFlagTv.setVisibility(View.GONE);
            viewHolder.mPraiseRecycler.setVisibility(View.VISIBLE);
        }
        praiseAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                FindInfo.LikeerArrayBean arrayBean = praiseAdapter.getData().get(position);
                goToUserInfoActivity(mActivity, arrayBean.getId() + "");
            }
        });
        //评论Adapter
        viewHolder.mCommentRecycler.setLayoutManager(new LinearLayoutManager(mContext));
        viewHolder.mCommentRecycler.setHasFixedSize(true);
        List<FindInfo.QuestionListBean.PartialTopCommentArrBean> commentArr = questionBean.getPartialTopCommentArr();
        final HxCommentAdapter commentAdapter = new HxCommentAdapter(mContext);
        //如果评论的size==3 加footer View
        if (commentArr != null && commentArr.size() == 3) {
            View footerView = LayoutInflater.from(mContext).inflate(R.layout.item_comment_footer, null, false);
            commentAdapter.addFooterView(footerView);
            TextView footerTv = (TextView) footerView.findViewById(R.id.footer_tv);
            footerTv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mActivity, FrendCircleActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("user", questionBean);
                    intent.putExtras(bundle);

                    mActivity.startActivity(intent);
                }
            });
        }
        commentAdapter.setNewData(commentArr);
        viewHolder.mCommentRecycler.setAdapter(commentAdapter);
        if (commentArr != null) {
            if (commentArr.size() == 0) {
                viewHolder.mCommentBgLv.setVisibility(View.GONE);
            } else {
                viewHolder.mCommentBgLv.setVisibility(View.VISIBLE);
            }
        }
        commentAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                FindInfo.QuestionListBean.PartialTopCommentArrBean commentArrBean = commentAdapter.getData().get(position);
                goToUserInfoActivity(mActivity, commentArrBean.getPublisher().getId() + "");
            }
        });


    }

    /**
     * 跳转到个人中心界面
     *
     * @param userid
     */
    private void goToUserInfoActivity(Activity activity, String userid) { //FriendInfoActivity
        Intent intent = new Intent(activity, HxPersonalCenterActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString(ImConstants.CLIENT_ID, userid);
        intent.putExtras(bundle);
        activity.startActivity(intent);
    }


    class FindViewHolder extends BaseViewHolder implements View.OnClickListener, HxCommonPopupWindow.ViewInterface {
        @BindView(R.id.find_icon)
        AvatarImageView mFindIcon;
        @BindView(R.id.item_find_nice_name)
        TextView        mItemFindNiceName;
        @BindView(R.id.item_find_info_time)
        TextView        mItemFindInfoTime;
        @BindView(R.id.item_find_info_delete)
        TextView        mItemFindInfoDelete;
        @BindView(find_guanzhu_txt)
        TextView        mFindGuanzhuTxt;
        @BindView(R.id.find_content_txt)
        TextView        mFindContentTxt;
        @BindView(R.id.find_grid_view)
        NineGridLayout  mFindGridView;
        @BindView(R.id.find_collect)
        TextView        mFindCollect;
        @BindView(R.id.find_comment)
        TextView        mFindComment;
        @BindView(R.id.find_zan)
        TextView        mFindZan;
        @BindView(R.id.item_find_ll_layout)
        RelativeLayout  mItemFindLlLayout;
        @BindView(R.id.praise_lv)
        RelativeLayout  mPraiseLv;

        @BindView(R.id.praise_recycler)
        RecyclerView mPraiseRecycler; //点赞RecyclerView
        @BindView(R.id.comment_recycler)
        RecyclerView mCommentRecycler; //评论RecyclerView
        @BindView(R.id.find_more_img)
        ImageView    mFindMoreImg;
        @BindView(R.id.comment_bg_lv)
        LinearLayout mCommentBgLv;
        @BindView(R.id.love_flag_tv)
        TextView     mLoveFlagTv;

        public FindViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, itemView);
            mFindGuanzhuTxt.setOnClickListener(this);
            mFindCollect.setOnClickListener(this);
            mFindZan.setOnClickListener(this);
            mItemFindInfoDelete.setOnClickListener(this);
            mFindMoreImg.setOnClickListener(this);
        }

        @Override
        public void onClick(View view) {
            //获取当前条目的信息
            final FindInfo.QuestionListBean mQuestionListBean = getItem(getLayoutPosition());
            final int questionId = mQuestionListBean.getQuestionId();
            switch (view.getId()) {
                case R.id.find_guanzhu_txt://关注
                    if (!mQuestionListBean.isIsFan()) {
                        final int userId = mQuestionListBean.getPublisher().getId();
                        HttpCommit httpCommit = new HttpCommit();
                        httpCommit.commitFan(userId);
                        httpCommit.setIsResponse(new HttpCommit.IsResponse() {
                            @Override
                            public void OnClock(boolean flag) {
                                if (flag) {
                                    EventBus.getDefault().post(new FocusDataEventBus(userId, mQuestionListBean.isIsFan()));
                                }
                            }
                        });
                    }
                    break;
                case R.id.find_collect://收藏

                    break;
                case R.id.find_zan://点赞

                    break;
                case R.id.item_find_info_delete:
                    HttpCommit.comitCircle(questionId);
                    getData().remove(getLayoutPosition());
                    notifyDataSetChanged();
                    break;
                case R.id.find_more_img:
                   if (mPopupWindow != null && mPopupWindow.isShowing())
                        return;
                    mPopupWindow = new HxCommonPopupWindow.Builder(mContext)
                            .setView(R.layout.dialog_like)
                            .setWidthAndHeight(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
                            .setAnimationStyle(R.style.AnimRight)
                            .setViewOnclickListener(this)
                            .create();

                    mPopupWindow.showAsDropDown(mFindMoreImg, -(mPopupWindow.getWidth() + 8), -(view.getHeight() + view.getHeight() / 2));

                    break;
            }
        }

        @Override
        public void getChildView(View view, int layoutResId) {
            //获取当前条目的信息
            final FindInfo.QuestionListBean mQuestionListBean = getItem(getLayoutPosition());
            final int questionId = mQuestionListBean.getQuestionId();
            LinearLayout mLikeLv = (LinearLayout) view.findViewById(R.id.like_lv);
            ImageView mLikeImg = (ImageView) view.findViewById(R.id.like_img);
            ImageView mCollectImg = (ImageView) view.findViewById(R.id.collect_img);

            LinearLayout mCollectLv = (LinearLayout) view.findViewById(R.id.collect_lv);
            setChangeLikeImgView(mLikeImg, mQuestionListBean.isIsLike());
            setChangeCollectImgView(mCollectImg,mQuestionListBean.isIsCollection());
            switch (layoutResId) {
                case R.layout.dialog_like:
                    mLikeLv.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            likeOnClick(mQuestionListBean, questionId, mFindZan);
                            mPopupWindow.dismiss();
                        }
                    });

                    mCollectLv.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            collectOnClick(mQuestionListBean, questionId, mFindCollect);
                            mPopupWindow.dismiss();
                        }
                    });
                    break;
            }
        }
    }

    /**
     * 收藏
     *
     * @param mQuestionListBean
     * @param questionId
     * @param findCollect
     */
    private void collectOnClick(FindInfo.QuestionListBean mQuestionListBean, final int questionId, TextView findCollect) {
        final boolean collection = mQuestionListBean.isIsCollection();
        final int collectionNum = mQuestionListBean.getCollectionNum();
        AnimationTools.scale(findCollect);
        HttpCommit httpCommit1 = new HttpCommit();
        httpCommit1.commitCollection(questionId);
        httpCommit1.setIsResponse(new HttpCommit.IsResponse() {
            @Override
            public void OnClock(boolean flag) {
                int flagCollectionNum;
                if (flag) {
                    if (!collection) {
                        ToastUtil.showToast("收藏成功");
                        flagCollectionNum = collectionNum + 1;
                    } else {
                        ToastUtil.showToast("取消收藏");
                        if (collectionNum == 0) {
                            flagCollectionNum = 0;
                        } else {
                            flagCollectionNum = collectionNum - 1;

                        }
                    }
                    EventBus.getDefault().post(new CollectDataEventBus(questionId, !collection, flagCollectionNum));
                }
            }
        });
    }

    /**
     * 点赞
     *
     * @param mQuestionListBean
     * @param questionId
     * @param findZan
     */
    private void likeOnClick(final FindInfo.QuestionListBean mQuestionListBean, final int questionId, TextView findZan) {
        final boolean islike = mQuestionListBean.isIsLike();
        final int likeerNum = mQuestionListBean.getLikeerNum();
        AnimationTools.scale(findZan);
        HttpCommit httpCommit2 = new HttpCommit();
        httpCommit2.commitLike(questionId);
        httpCommit2.setIsResponse(new HttpCommit.IsResponse() {
            @Override
            public void OnClock(boolean flag) {
                int flagLikeerNum = 0;
                if (flag) {
                    if (!islike) { //点赞成功
                        flagLikeerNum = likeerNum + 1;
                        ToastUtil.showToast("点赞成功");
                    } else { //取消点赞
                        ToastUtil.showToast("取消点赞");
                        if (likeerNum == 0) {
                            flagLikeerNum = 0;
                        } else {
                            flagLikeerNum = likeerNum - 1;

                        }
                        for (int i = 0; i < mQuestionListBean.getLikeerArray().size(); i++) {
                            FindInfo.LikeerArrayBean arrayBean = mQuestionListBean.getLikeerArray().get(i);
                            if (arrayBean.getId() == Global.user.getUserId()) {
                                mQuestionListBean.getLikeerArray().remove(i);
                            }
                        }
                    }
                }
                FindInfo.LikeerArrayBean arrayBean = new FindInfo.LikeerArrayBean();
                arrayBean.setId(Global.user.getUserId());
                arrayBean.setImg(Global.user.getImgUrl());
                arrayBean.setNickName(Global.user.getNickName());
                EventBus.getDefault().post(new LikeDataEventBus(questionId, !islike, flagLikeerNum, arrayBean));
            }
        });
    }


    /**
     * @desc 设置关注TextView
     * @author songxf
     * created at 2017/6/30 16:22
     */
    private void setChangeFcousTv(TextView focusTv, boolean isfocu) {
        Drawable drawable;
        if (isfocu) {//关注
            focusTv.setTextColor(Color.parseColor("#FFA7A6A6"));
            focusTv.setText("已关注");
            drawable = mContext.getResources().getDrawable(R.drawable.feed_picture_10);
        } else {
           /* focusTv.setTextColor(Color.parseColor("#419ee1"));
            focusTv.setText("关注");*/
            drawable = mContext.getResources().getDrawable(R.drawable.guanzhu_13);
        }
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        focusTv.setCompoundDrawables(drawable, null, null, null);
    }

    /**
     * @desc 设置收藏图片
     * @author songxf
     * created at 2017/6/30 16:22
     */
    private void setChangeCollectImg(TextView collctTv, boolean iscollect) {
        Drawable drawable;
        if (iscollect) {
            drawable = mContext.getResources().getDrawable(R.drawable.star_selected);
        } else {
            drawable = mContext.getResources().getDrawable(R.drawable.star_normal);
        }
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        collctTv.setCompoundDrawables(drawable, null, null, null);
    }

    private void setChangeLikeImgView(ImageView collctImg, boolean isCollect) {
        Drawable drawable;
        if (isCollect) {
            drawable = mContext.getResources().getDrawable(R.drawable.love_selected);
        } else {
            drawable = mContext.getResources().getDrawable(R.drawable.love_normal);
        }
        collctImg.setBackground(drawable);
    }
    private void setChangeCollectImgView(ImageView collctImg, boolean isCollect) {
        Drawable drawable;
        if (isCollect) {
            drawable = mContext.getResources().getDrawable(R.drawable.star_selected);
        } else {
            drawable = mContext.getResources().getDrawable(R.drawable.star_normal);
        }
        collctImg.setBackground(drawable);
    }

    /**
     * @desc 设置点赞图片
     * @author songxf
     * created at 2017/6/30 16:22
     */
    private void setChangeZanImg(TextView collctTv, boolean iscollect) {
        Drawable drawable;
        if (iscollect) {
            drawable = mContext.getResources().getDrawable(R.drawable.love_selected);
        } else {
            drawable = mContext.getResources().getDrawable(R.drawable.love_normal);
        }
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        collctTv.setCompoundDrawables(drawable, null, null, null);
    }
}
